﻿using Microsoft.AspNetCore.Mvc;
using yunbo.Model.SM;
using yunbo.Repositorys.FPMRepositorys;

namespace yunbo.Controllers.SMControllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class WMS_CCPRKXXController : Controller
    {
        WMS_CCPRKXXRepository WMS_CCPRKXXRepository = new WMS_CCPRKXXRepository();

        [HttpPost("AddCCPRKXX")]
        public IActionResult AddCCPRKXX(WMS_CCPRKXX wMS_CCPRKXX)
        {
            string currentTime = DateTime.Now.ToString("yyyyMMdd");

            // 生成一个四位随机数
            Random random = new Random();
            int randomNumber = random.Next(1000, 10000); // 生成1000到9999之间的随机数
            string randomNumberString = randomNumber.ToString("D4"); // 格式化为四位数字字符串

            // 组合当前时间和随机数生成ID
            string id = $"rkxx{currentTime}{randomNumberString}";
            wMS_CCPRKXX.cprkxx_code = id;
            bool ll = WMS_CCPRKXXRepository.AddWMS_CCPRKXX(wMS_CCPRKXX) > 0;
            return Ok(ll);
        }
        [HttpGet("GetCCPRKXX")]
        public IActionResult GetCCPRKXX(string code)
        {
            List<WMS_CCPRKXX> wMS_CCPRKXXes = WMS_CCPRKXXRepository.GetWMS_CCPRKXXes(code);
            return Ok(wMS_CCPRKXXes);
        }
    }
}
